<%@page import="com.wanmait.hotelManage.vo.Pager"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.text.DateFormat"%>
<%@page import="com.wanmait.hotelManage.vo.News"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
String path=request.getContextPath();
List<News>news=(List<News>)request.getAttribute("news");
%>
<jsp:include page="/inc/header.jsp"></jsp:include>

     <!--中标题-->
    <section class="page-title text-center">
        <div class="auto-container">
            <div class="content-box">
                <div class="title">酒店新闻</div>
                <ul class="bread-crumb">
                    <li><a href="<%=path%>">主页<i class="fa fa-angle-right"></i></a></li>
                    <li>酒店新闻</li>
                </ul>
            </div>
        </div>
    </section>
    <!--End Page Title-->

    <!-- 新新闻-->
    <span class="e">
    <section class="sidebar-page-container news-section latest-news">
        <div class="container">
            <div class="rowww">
                <div  style="margin-left: 200px;" class="content-side col-md-8 col-sm-8 col-xs-12">
                    <div class="blog-classic-section">
                       	<!--小新闻-->
                       	<%
                       	if(news!=null){
                       		DateFormat df=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                       		for(int i=0;i<news.size();i++){
                       			News ne=news.get(i);
                       			String inputTime=df.format(ne.getInputTime());
                       			%>
                       			 <div class="single-item  wow fadeInUp animated animated animated animated">
                            <div class="img-box">
                                <a href="<%=path%>/NewsListServlet?action=search&id=<%=ne.getId()%>">
                                <figure><img style="width:770px;height:520px" src="<%=path %>/static/images/news/<%=ne.getPic() %>" alt=""></figure></a>
                            </div>
                            <div class="news-content">
                                <a href="<%=path%>/NewsListServlet?action=search&id=<%=ne.getId()%>"><h3><%=ne.getTitle() %></h3></a>
                               <span style="margin-left:300px"><%=inputTime %></span>
                            </div>
                            <p><%=ne.getIntr() %></p>
                        </div>
                       			<%
                       		}
                       	}
                       	%>
                    </div>
                </div>
                </div>
            </div>
          <div class="qwe">
                     <%
                     Pager pager=(Pager)request.getAttribute("pager");
                     if(pager!=null){
                     	 int start= 1;
                          int end =pager.getPageCount();
                          if(pager.getPageCount()>5){
                         	 start=pager.getPageNo()-2<1?1:pager.getPageNo()-2;
                         	 end=start+4;
                         	 if(end>pager.getPageCount()){
                         		 end=pager.getPageCount();
                         		 start=end-4;
                         	 }
                          }
                          %>
                          [<a class="ok" href="javascript:void(0)">上一页</a>]
                          <%
                     	for(int i=start;i<=end;i++){
                     		%>
                     		[<a class="number" href="javascript:void(0)"><%=i %></a>]
                     		<%
                     	}
                          %>
                          [<a class="no" href="javascript:void(0)">下一页</a>]
                          <%
                     }
                     %>
                    </div>
    </section>
    </span>
    <!-- latest news end -->
    
<jsp:include page="/inc/footer.jsp"/>
<style>
.qwe{
text-align:center;
}
</style>
<script>
$(function(){
	$(".no").click(function(){
		/* $(".number").css("color","black");
		$(this).css("color","red"); */
		var cont=<%=pager.getPageNo()%>;
		if(cont<<%=pager.getPageCount()%>){
			cont++;
		}
		$.ajax({
			url:"<%=path%>/NewsListServlet?action=initTwo",
				data:{id:cont},
					success:function(msg){
						$(".e").html(msg);
					}
		})
	})
$(".ok").click(function(){
/* $(".number").css("color","black");
$(this).css("color","red"); */
var cont=<%=pager.getPageNo()%>;
if(cont>1){
cont--;
}
$.ajax({
url:"<%=path%>/NewsListServlet?action=initTwo",
data:{id:cont},
success:function(msg){
	$(".e").html(msg);
}
})
})
	$(".number").click(function(){
		 $(".number").css("color","black");
		$(this).css("color","red"); 
		var cont=$(this).html();
		/* if($(".number").html()==cont){
			th=$(this)
		} */
		$.ajax({
			url:"<%=path%>/NewsListServlet?action=initTwo",
				data:{id:cont},
					success:function(msg){
						$(".e").html(msg);
					}
		})
	})
})
</script>
